package tw.asap.plus.ui;

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import net.steamcrafted.loadtoast.LoadToast;

import tw.asap.plus.R;
import tw.asap.plus.app.NearApplication;
import tw.asap.plus.utils.ScreenUtil;


/**
 * Created by yamlee on 15/8/7.
 */
public class BaseFragment extends Fragment {
    public LoadToast baseLoadToast;


    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        baseLoadToast = new LoadToast(activity);
        baseLoadToast.setBackgroundColor(getResources().getColor(R.color.palette_white))
                .setProgressColor(getResources().getColor(R.color.palette_red))
                .setTextColor(getResources().getColor(R.color.palette_red));
        baseLoadToast.setTranslationY(ScreenUtil.dip2px(NearApplication.getNearApplicationContext(), 50));
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    public void changeFragment(Fragment fragment){
        if(fragment.getArguments() ==null){
            fragment.setArguments(new Bundle());
        }
        BaseActivity baseActivity = (BaseActivity) getActivity();
        baseActivity.changeFragment(fragment);
    }

    public void initFragment(Fragment fragment){
        if(fragment.getArguments() ==null){
            fragment.setArguments(new Bundle());
        }
        BaseActivity baseActivity = (BaseActivity) getActivity();
        baseActivity.initFragment(fragment);
    }


}
